package com.example.mqdemo.direct;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
 *@description: 主题订阅模式配置文件
 *@author: hisen
 *@Time: 2023/11/23  17:40
 */
@Configuration
public class DirectConfig {
    @Bean
    public Queue directQueue1() {
        return new Queue("directQueue1");
    }

    @Bean
    public Queue directQueue2() {
        return new Queue("directQueue2");
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("directExchange");
    }

    @Bean
    public Binding directBinding1(@Qualifier("directQueue1") Queue directQueue, DirectExchange directExchange) {
        return BindingBuilder.bind(directQueue).to(directExchange).with("error");
    }

    @Bean
    public Binding directBinding2(@Qualifier("directQueue2") Queue directQueue, DirectExchange directExchange) {
        return BindingBuilder.bind(directQueue).to(directExchange).with("info");
    }
}
